package com.ljf.framework.socket;


/**
 * 说明：
 *
 * @Auther: lijinfeng
 * @Date: 2023/9/25
 */
public class LjfSocketManager {


    public static void main(String[] args) {
        start();
    }

    /**
     * 运行Socket服务
     */
    public static void start(){
        getLjfSocketConfig().init();
    }




    public static void getSocketHandler() {

    }


    public static int getPort() {
        return getLjfSocketConfig().getPort();
    }

    /**
     * socket 配置服务
     */
    private volatile static LjfSocketConfig ljfSocketConfig;
    public static void setLjfSocketConfig(LjfSocketConfig ljfSocketConfig) {
        LjfSocketManager.ljfSocketConfig = ljfSocketConfig;
    }
    public static LjfSocketConfig getLjfSocketConfig() {
        if (ljfSocketConfig == null) {
            synchronized (LjfSocketManager.class) {
                if (ljfSocketConfig == null) {
                    setLjfSocketConfig(new LjfSocketConfigDefaultImpl());
                }
            }
        }
        return ljfSocketConfig;
    }

    /**
     * socket 消息处理器
     */
    private volatile static LjfSocketMessageHandler ljfSocketMessageHandler;
    public static void setLjfSocketMessageHandle(LjfSocketMessageHandler ljfSocketMessageHandle) {
        LjfSocketManager.ljfSocketMessageHandler = ljfSocketMessageHandle;
    }
    public static LjfSocketMessageHandler getLjfSocketMessageHandle() {
        if (ljfSocketMessageHandler == null) {
            synchronized (LjfSocketManager.class) {
                if (ljfSocketMessageHandler == null) {
                    setLjfSocketMessageHandle(new LjfSocketMessageHandlerDefaultImpl());
                }
            }
        }
        return ljfSocketMessageHandler;
    }


}
